package com.block.common.sign.factory;

import com.block.common.sign.enums.SignTypeEnum;
import com.block.common.sign.service.ISignTypeServcie;
import com.block.common.sign.service.type.DefaultService;
import com.block.common.sign.service.type.V1SigntService;
import com.block.common.util.ApplicationContextUtil;

import java.util.HashMap;
import java.util.Map;

public class SignFactory {

    private static Map<String, Class<? extends ISignTypeServcie>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(SignTypeEnum.V1.getValue(), V1SigntService.class);
    }

    public static ISignTypeServcie getService(String type){
        if (serviceMap.containsKey(type)){
            Class<? extends ISignTypeServcie> aClass = serviceMap.get(type);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultService.class);
    }
}
